/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import liquibase.pro.packaged.V;
import org.springblade.core.mp.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.modules.admin.vo.user.SalaryVo;

import java.util.List;

/**
 * 用户工资表实体类
 *
 * @author ysq
 * @since 2025-06-10
 */
@Data
@TableName(value = "blade_user_salary_rules_history", autoResultMap = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "UserSalaryRulesHistory对象", description = "用户工资表")
public class UserSalaryRulesHistory extends TenantEntity {

	private static final long serialVersionUID = 1L;

	/**
	 * 模板id
	 */
	@ApiModelProperty(value = "模板id")
	private Long templateId;
	/**
	 * 模板名称
	 */
	@ApiModelProperty(value = "模板名称")
	private String templateName;
	/**
	 * 规则字典值
	 */
	@ApiModelProperty(value = "规则字典值")
	private Integer rulesType;
	/**
	 * 排序
	 */
	@ApiModelProperty(value = "排序")
	private Integer sort;
	/**
	 * 字段名称
	 */
	@ApiModelProperty(value = "字段名称")
	private String name;
	/**
	 * 字段类型
	 */
	@ApiModelProperty(value = "字段类型")
	private String nameType;
	/**
	 * 对应前端的字段名称
	 */
	@ApiModelProperty(value = "对应前端的字段名称")
	private String vueName;
	/**
	 * 1文本2:数值3:百分比4:数值|收入5:数值|扣减
	 */
	@ApiModelProperty(value = "1文本2:数值3:百分比4:数值|收入5:数值|扣减")
	private String salaryType;
	/**
	 * 字段属性
	 */
	@ApiModelProperty(value = "字段属性")
	private String nameAttribute;
	/**
	 * 计算规则
	 */
	@ApiModelProperty(value = "计算规则")
	private String calculatorRules;
	/**
	 * 规则明细
	 */
	@ApiModelProperty(value = "规则明细")
	@TableField(typeHandler = JacksonTypeHandler.class)
	private List<SalaryVo> rulesDetail;
	/**
	 * 业务id
	 */
	@ApiModelProperty(value = "业务id")
	private Long salaryMonthId;

	public void setRulesDetail(List<SalaryVo> rulesDetail) {
		if (rulesDetail != null && rulesDetail.size() > 0) {
			this.rulesDetail = JSON.parseArray(JSON.toJSONString(rulesDetail), SalaryVo.class);
		} else {
			this.rulesDetail = rulesDetail;
		}
	}

}
